package com.justgame.project.cloud.common.util;

import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

/**
 * 数组 / 集合工具
 */
public class ArrayUtils {
    public static <T> boolean isEmpty(T[] objects){
        return Objects.isNull(objects) || objects.length == 0;
    }

    public static <T> boolean isEmpty(Collection<T> objects){
        return Objects.isNull(objects) || objects.isEmpty();
    }

    @SafeVarargs
    public static <T> T[] asArray(T... objects){
        return objects;
    }

    public static <T> T[] asArray(List<T> objects){
        return (T[]) objects.toArray();
    }

    public static <T> boolean notEmpty(T[] objects){
        return !isEmpty(objects);
    }

    public static <T> boolean notEmpty(Collection<T> objects){
        return !isEmpty(objects);
    }
}
